<?php

if($_GET['type']=='list'){	 
	 if(isset($_POST['srch-term'])){
		 $db=new db;
		 $db->connect();
		
		 $sql ="select id,username,name,avatar,facebook_id,date_registered,group_id from users where username like '%".$db->security($_POST['srch-term'])."%' or name like '%".$db->security($_POST['srch-term'])."%'   order by group_id asc";
		 $db->query($sql);
		 $data['info']=$db->fetchAll();
		 
		 
		
	 }else{
	
	$cache=new Cache;
	$sql ="select id,username,avatar,facebook_id,date_registered,group_id from users   order by group_id asc";
	$sql2="select id from users";
	//$url=HOME."index.php?module=news&act=type&type=blog&action=home&page=";
	$url=HOME."member/";
	$pager = new Pagination($sql,15,6,$url,500);
	$pager->setDebug(false);
	$data[info] = $pager->paginate($cache,$sql2);
	$data[nav]	= $pager->renderFullNav();
	 }
	
$data1['title']=web_title("Thành Viên Mộng.vn");
$data1['keyword']=web_keyword(" Thành viên mong.vn, thành viên Channel");
$data1['mota']=web_des('Khu vực thành viên ');
loadview('template/header',$data1);
loadview("user/channel",$data);
}
if($_GET['type']=='user'){
	$data['user'] =cache_get_user($_GET['user']);
	   		// CALCULATOR VIEW --------
		//HEADER TITLE,KEYWORD,DESCRIPION
		//Nếu user visit channel thì nếu có comment, sẽ udpate index=0 , vì nếu có comment mới mình sẽ set inbox =1 ^^
		if(isset($_SESSION['user']))
		if($_SESSION['user']['username']==$_GET['user']){
			// User đã check channel của mình, udpate inbox = 0;
			$db=new db;
			$db->connect();
			$db->nonquery('update users set inbox=0 where username="'.$db->security($_SESSION['user']['username']).'"');
			$db->close();
		}
	
	$data1['title']=$_GET['user'] ." Channel";
	$data1['keyword']=$_GET['user'] ." Channel";
	$data1['mota']=$_GET['user'] .' Channel'.' | Mong.vn';

	loadview('template/header',$data1);
	loadview("user/channel",$data);
}

?>